<template>
    <div class="FormView">
        <div class="FormModuleView">
            <div class="FormViewTitle">用频参数</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.BasicParam" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value"></component>
                </div>
            </Form>
        </div>
        <div class="FormModuleView" v-if="value.TranRevList[0].TranParam">
            <div class="FormViewTitle">发射机</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.TranParam" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value.TranRevList[0]" @ChangeFreqType="ChangeFreqType"></component>
                </div>
            </Form>
        </div>
        <div class="FormModuleView" v-if="value.TranRevList[0].TranAntData && value.TranRevList[0].IsER == 0">
            <div class="FormViewTitle">发射机天线</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.TranAntData" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value.TranRevList[0]"></component>
                </div>
            </Form>
        </div>

        <div class="FormModuleView" v-if="value.TranRevList[0].RevParam">
            <div class="FormViewTitle">接收机</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.RevParam" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value.TranRevList[0]" @ChangeFreqType="ChangeFreqType"></component>
                </div>
            </Form>
        </div>

        <div class="FormModuleView" v-if="value.TranRevList[0].RevAntData && value.TranRevList[0].IsER == 0">
            <div class="FormViewTitle">接收机天线</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.RevAntData" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value.TranRevList[0]"></component>
                </div>
            </Form>
        </div>

        <div class="FormModuleView" v-if="value.TranRevList[0].RevAntData && value.TranRevList[0].IsER == 1">
            <div class="FormViewTitle">公用天线</div>
            <Form label-position="left" label-width="120px">
                <div v-for="item in Configs.RevAntData" :key="item.ParamKey">
                    <component v-show="item.show" :is="'FormItem' + item.Type" :Config="item" v-model="value.TranRevList[0]"></component>
                </div>
            </Form>
        </div>
    </div>
</template>

<script>
import FormItemNumber from './FormItemNumber.vue'
import FormItemSelect from './FormItemSelect.vue'
import FormItemText from './FormItemText.vue'

export default {
    props: ['Configs', 'value'],
    components: {
        FormItemNumber,
        FormItemSelect,
        FormItemText
    },
    methods: {
        ChangeFreqType(Config, Value) {
            var value = Value[Config.ParentKey].FreqType
            var _Config = this.Configs[Config.ParentKey]
            for (let i = 0; i < _Config.length; i++) {
                const element = _Config[i]
                if (element.ParamKey == 'FreqCenter' || element.ParamKey == 'BandWidth' || element.ParamKey == 'OccupyBand') {
                    element.show = value == 0
                } else if (element.ParamKey == 'FreqTo' || element.ParamKey == 'FreqFrom') {
                    element.show = value == 1
                }
            }
        }
    }
}
</script>
<style lang="less" scoped>
.FormViewTitle {
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px;
    margin-bottom: 5px;
    font-size: 15px;
}
</style>